import { defineStore } from 'pinia'
import { ref } from 'vue'

const useAppStore = defineStore('app', () => {
  const top = ref(0)
  const minHeight = ref(0)
  // // 获取系统信息
  // const systemInfo = uni.getSystemInfoSync()
  // 获取安全区域和平台信息
  // const { safeArea, platform } = systemInfo
  // let top = 20
  // if (safeArea && safeArea.top >= 20) {
  //   top = safeArea.top
  // }
  const safeArea = ref<any>({})
  let platform: string = ''
  let system: string = ''
  const reset = () => {
    // 获取系统信息
    const systemInfo: any = uni.getSystemInfoSync()
    // 获取安全区域和平台信息
    // const { safeArea1, platform1 } = systemInfo
    safeArea.value = systemInfo.safeArea
    platform = systemInfo.platform
    system = systemInfo.system
    console.log('zzz', systemInfo, safeArea, platform)
    top.value = systemInfo.statusBarHeight
	minHeight.value = systemInfo.windowHeight
  }
  // 定义computed计算属性就是等同于定义getters
  // const doubleMoney = computed(() => {
  //   return top.value * 2
  // })
  return { safeArea, platform, system, top, reset, minHeight }
})

export default useAppStore
